﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Estimate.Common.NewReport.DataProvider;
using Estimate.Common.Repository;
using Estimate.Common.Estimate;
using Estimate.Common.Entity;

namespace Estimate.Common.NewReport.DataProvider
{
    public class CollectionDataProvider : INewReportDataProvider
    {
        public ForeRepository _repository;
        private string _stationCodes;
        public CollectionDataProvider(string codes, ForeRepository repository)
        {
            _repository = repository;
            _stationCodes = codes;
        }

        public Entity.ForeEntity[] InquerySemiWithDateRange(DateTime beginDate, DateTime endDate, DBFieldTypes.ForeClockType[] clocks, DBFieldTypes.ForeSpanType span, DBFieldTypes.ForeSendpointType[] sendpoints, DBFieldTypes.ForeFactorType type, DBFieldTypes.ForeSemiType semitype)
        {
            ForeEntity[] semis = _repository.InquerySemiWithDateRange(beginDate, endDate, clocks, span, sendpoints, type, semitype,true);

            if (_stationCodes.Length > 0)
            {
                for (int i = 0; i < semis.Length; i++)
                {
                    semis[i].Semi = _repository.FilterSemiWithStationIds(semis[i].Semi, _stationCodes);
                }
            }
            return semis;
        }
    }
}
